package com.zhenwei.zscm.common.base;

import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.zhenwei.zscm.model.dto.user.UserDTO;

import java.util.Date;

public class MybatisWrapper {
    /**
     * 填充更新人、更新时间字段，要求Entity必须继承BaseEntity
     * @param wrapper wrapper
     */
    public static void fillUser(LambdaUpdateWrapper<? extends BaseEntity> wrapper) {
        UserDTO user = UserContext.getCurrentUser();
        wrapper.set(BaseEntity::getUUser, user.getRealName());
        wrapper.set(BaseEntity::getUUserId, user.getGuid());
        wrapper.set(BaseEntity::getUTime, new Date());
    }
}
